<?php
header("Expires: Mon, 13 jan 2007 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
echo"<html>
<head><style type=\"text/css\">body { font-family: Verdana,Arial,Helvetica,sans-serif;
	font-size: 11px;
	}
	</style>
	</head>
	<body>";

	include("./include/_28e/28e.php");


	include("./include/core/const.php");
	include("./include/core/bfunc.php");

	$link = dbconnect($db_host, $db_user, $db_pass, $db_name);
	mysql_query("set names cp1251"); //$db_pref


	if(!sql_table_exists($db_pref."users")){
		echo"<br />Creating table <b>'".$db_pref."users'</b>..." . str_repeat("    ",1024);
		$result = dbquery("DROP TABLE IF EXISTS ".$db_pref."users");
		$result = dbquery("CREATE TABLE ".$db_pref."users (
			user_id INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,

			username VARCHAR(64) NOT NULL DEFAULT '',
			usernamelow VARCHAR(32) NOT NULL DEFAULT '',
			password VARCHAR(32) NOT NULL DEFAULT '',
			usernameoriginal VARCHAR(64) NOT NULL DEFAULT '',
			
			email VARCHAR(100) NOT NULL DEFAULT '',
			hide_email TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',

			user_web VARCHAR(200) NOT NULL DEFAULT '',
			user_locate VARCHAR(32) NOT NULL DEFAULT '',
			user_sex CHAR(3) NOT NULL DEFAULT '0',

			count_posts SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',

			createuser INT(10) UNSIGNED NOT NULL DEFAULT '0',
			lastvisit INT(10) UNSIGNED NOT NULL DEFAULT '0',
			
			use_showdate_ex TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
			count_list_th SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
			count_list_posts SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',

			user_birthdate DATE NOT NULL DEFAULT '0000-00-00',
	
			banned TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
			ro_long INT(10) UNSIGNED NOT NULL DEFAULT '0',
			ro_start INT(10) UNSIGNED NOT NULL DEFAULT '0',

			user_level TINYINT(3) UNSIGNED NOT NULL DEFAULT '101',

			user_about TEXT NOT NULL,

			PRIMARY KEY (user_id),
			KEY usernamelow (usernamelow)

		) TYPE=MyISAM;");
	
		dbquery("INSERT INTO ".$db_pref."users (username,usernamelow, password, usernameoriginal,email, hide_email, createuser, lastvisit, user_level ) VALUES ('admin','admin', '".strtolower(md5('admin'))."','Administrator','desksoft@gmail.com', '1', '".time()."', '".time()."','103')");

		
		dbquery("OPTIMIZE TABLE `".$db_pref."users`");
		echo"<b>...done</b>. Table <b>'users'</b> imported." . str_repeat("    ",1024);
	}else{
		echo"<br />Table <b>'users'</b> alredy created" . str_repeat("    ",1024);
	}

	if(!sql_table_exists("".$db_pref."vcode")){
		echo"<br />Creating table <b>'".$db_pref."vcode'</b>..." . str_repeat("    ",1024);
		$result = dbquery("DROP TABLE IF EXISTS ".$db_pref."vcode");
		$result = dbquery("CREATE TABLE ".$db_pref."vcode (
			vcode_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
			vcode_datestamp INT(10) UNSIGNED NOT NULL DEFAULT '0',
			vcode_1 VARCHAR(16) NOT NULL DEFAULT '',
			vcode_2 VARCHAR(32) NOT NULL DEFAULT '',
			vcode_3 INT(10) UNSIGNED NOT NULL DEFAULT '0',
			PRIMARY KEY (vcode_id),
			KEY vcode_2 (vcode_2),
			KEY vcode_datestamp (vcode_datestamp)
		) TYPE=MyISAM;");
	}else{
		echo"<br />Table <b>'".$db_pref."vcode'</b> alredy created" . str_repeat("    ",1024);
	}

	if(!sql_table_exists("".$db_pref."forums")){
		echo"<br />Creating table <b>'".$db_pref."forums'</b>..." . str_repeat("    ",1024);
		$result = dbquery("DROP TABLE IF EXISTS ".$db_pref."forums");
		$result = dbquery("CREATE TABLE ".$db_pref."forums (
			forum_id INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
			forum_cat INT(5) UNSIGNED NOT NULL DEFAULT '0',
			forum_name VARCHAR(100) NOT NULL DEFAULT '',
			forum_order INT(5) UNSIGNED NOT NULL DEFAULT '0',
			forum_description TEXT NOT NULL,
			forum_moderators TEXT NOT NULL,
			PRIMARY KEY (forum_id)
		) TYPE=MyISAM;");
		echo"<b>...done</b>.";
		echo" Fill table <b>'".$db_pref."forums'</b>..." . str_repeat("    ",1024);
				

		echo"<b>...done</b>. Table <b>'".$db_pref."forums'</b> imported." . str_repeat("    ",1024);
	}else{
		echo"<br />Table <b>'".$db_pref."forums'</b> alredy created" . str_repeat("    ",1024);
	}

	if(!sql_table_exists("".$db_pref."forum_threads")){
		echo"<br />Creating table <b>'".$db_pref."forum_threads'</b>..." . str_repeat("    ",1024);
		$result = dbquery("DROP TABLE IF EXISTS ".$db_pref."forum_threads");
		$result = dbquery("CREATE TABLE ".$db_pref."forum_threads (
			forum_id INT(5) UNSIGNED NOT NULL DEFAULT '0',
			thread_id INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
			thread_subject VARCHAR(100) NOT NULL DEFAULT '',
			thread_author VARCHAR(32) NOT NULL DEFAULT 'guest',
			thread_user_id INT(5) UNSIGNED NOT NULL DEFAULT '0',
			thread_views SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
			thread_lastpost INT(10) UNSIGNED NOT NULL DEFAULT '0',
			thread_sticky TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
			thread_locked TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
			thread_ico SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
			thread_preview TEXT NOT NULL,
			thread_posting TEXT NOT NULL,
			PRIMARY KEY (thread_id),
			KEY forum_id (forum_id),
			KEY thread_user_id (thread_user_id)
		) TYPE=MyISAM;");
		echo"<b>...done</b>.";
	}else{
		echo"<br />Table <b>'".$db_pref."forum_threads'</b> alredy created" . str_repeat("    ",1024);
	}

	if(!sql_table_exists("".$db_pref."forum_posts")){
		echo"<br />Creating table <b>'".$db_pref."forum_posts'</b>..." . str_repeat("    ",1024);
		$result = dbquery("DROP TABLE IF EXISTS ".$db_pref."forum_posts");
		$result = dbquery("CREATE TABLE ".$db_pref."forum_posts (
			forum_id INT(5) UNSIGNED NOT NULL DEFAULT '0',
			thread_id INT(5) UNSIGNED NOT NULL DEFAULT '0',
			post_id INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
			post_subject VARCHAR(100) NOT NULL DEFAULT '',
			post_user_id INT(5) UNSIGNED NOT NULL DEFAULT '0',
			post_author VARCHAR(32) NOT NULL DEFAULT 'guest',
			post_datestamp INT(10) UNSIGNED NOT NULL DEFAULT '0',
			post_edituser INT(5) UNSIGNED NOT NULL DEFAULT '0',
			post_edittime INT(10) UNSIGNED NOT NULL DEFAULT '0',
			post_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
			post_ip VARCHAR(20) NOT NULL DEFAULT '0.0.0.0',
			post_message TEXT NOT NULL,
			PRIMARY KEY (post_id),
			KEY thread_id (thread_id),
			KEY forum_id (forum_id),
			KEY post_user_id (post_user_id)
		) TYPE=MyISAM;");
		echo"<b>...done</b>.";
		echo" Fill table <b>'".$db_pref."forum_posts'</b>..." . str_repeat("    ",1024);
				

		echo"<b>...done</b>. Table <b>'".$db_pref."forum_posts'</b> imported." . str_repeat("    ",1024);
	}else{
		echo"<br />Table <b>'".$db_pref."forum_posts'</b> alredy created" . str_repeat("    ",1024);
	}

	if(!sql_table_exists($db_pref."ip_list")){
		echo"<br />Creating table <b>'".$db_pref."ip_list'</b>..." . str_repeat("    ",1024);
		$result = dbquery("DROP TABLE IF EXISTS ".$db_pref."ip_list");
		$result = dbquery("CREATE TABLE ".$db_pref."ip_list (
			id INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
			IP VARCHAR(20) NOT NULL DEFAULT '0.0.0.0',
			ro TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
			ro_long INT(10) UNSIGNED NOT NULL DEFAULT '0',
			ro_start INT(10) UNSIGNED NOT NULL DEFAULT '0',

			ban TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
			ban_long INT(10) UNSIGNED NOT NULL DEFAULT '0',
			ban_start INT(10) UNSIGNED NOT NULL DEFAULT '0',

			last_visit INT(10) UNSIGNED NOT NULL DEFAULT '0',
			count_visit INT(10) UNSIGNED NOT NULL DEFAULT '0',
			PRIMARY KEY (id),
			KEY IP (IP)
		) TYPE=MyISAM;");


		//generator
		echo"<br><b>generator</b>";
		
		dbquery("INSERT INTO ".$db_pref."ip_list (IP) VALUES ('0.0.0.0')");
		dbquery("OPTIMIZE TABLE `".$db_pref."ip_list`");
		echo"<br><b>...done</b>";

		

	}else{
		echo"<br />Table <b>'".$db_pref."ip_list'</b> alredy created" . str_repeat("    ",1024);
	}


	echo"<br /><br />Done.</body></html>";
	exit;

?>